#!/usr/bin/env python3
#!-*- coding:utf-8 -*-

from neo4j.v1 import GraphDatabase
import xlrd

# 导出某领域专家的总数

uri = "bolt://47.104.244.119:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "zhongyi!@#2018"))


def print_scholarNum(field):
    with driver.session() as session:
        with session.begin_transaction() as tx:
            for num in tx.run("match(e:expert)<-[r:containse]-(f:field) where f.name={field} return count(e)", field=field):
                print(num["count(e)"])


# 打开excel文件
worksheet = xlrd.open_workbook('D:/fos.xlsx')
# 根据Sheet名获取数据
sheet2 = worksheet.sheet_by_name('computer ')
# 表示获取Sheet2中第4行数据
# rows = sheet2.row_values(3)
# 表示获取Sheet2中第1列数据（数据保存为list）
cols0 = sheet2.col_values(3)
for item in cols0:
    print_scholarNum(item)




# f = open("D:/scholarPaperCount.txt", 'a')

# f.write("hello\n")








